﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using bsn=CodeGecko.AntiSpam.BlogSpamNet;
using bsns=CodeGecko.AntiSpam.BlogSpamNet.Structs;

namespace umbraco.blog4.spam {
    public class BlogSpamNetChecker : SpamChecker {
        private bsn.BlogSpamNet api = new bsn.BlogSpamNet();

        #region .ctor
        public BlogSpamNetChecker() { this.ProviderName = "BlogSpam.net"; }
        #endregion

        public override Boolean Check(int nodeid, string UserAgent, string UserIp, string Author, string AuthorEmail, string AuthorUrl, string Content) {
            return api.CommentCheck(new bsns.Comment() {
                agent = UserAgent,
                ip = UserIp,
                name = Author,
                email = AuthorEmail,
                link = AuthorUrl,
                comment = Content,
                site = HttpContext.Current.Request.ServerVariables["SERVER_NAME"]
            });
        }

        public override void MarkAsHam(int nodeid, string Author, string AuthorEmail, string AuthorUrl, string Content) {
            api.SubmitHam(new bsns.Comment() { name = Author, email = AuthorEmail, link = AuthorUrl, comment = Content });
        }

        public override void MarkAsSpam(int nodeid, string Author, string AuthorEmail, string AuthorUrl, string Content) {
            api.SubmitSpam(new bsns.Comment() { name = Author, email = AuthorEmail, link = AuthorUrl, comment = Content });
        }
    }
}